var util = require('../../../utils/util.js');
var api = require('../../../config/api.js');

var app = getApp();
Page({

  /**
   * 页面的初始数据
   */
  data: {
    withdrawAmount: 0.00,//可提现额度
    userId: '',//用户id
  },
  getMyCommission(){
    var that = this;
    util.request(api.getMyCommission, { userId: that.data.userId}).then(function(res){
      console.log("-------res:" + JSON.stringify(res));
      if (res != null){
        that.setData({
          withdrawAmount: res.withdrawAmount
        })
      }
    })
  },
  /**
   * 生命周期函数--监听页面加载
   */
  onLoad: function (options) {
  
  },

  /**
   * 生命周期函数--监听页面初次渲染完成
   */
  onReady: function () {

  },

  /**
   * 生命周期函数--监听页面显示
   */
  onShow: function () {
    //获取用户的登录信息
    if (app.globalData.hasLogin) {
      let userInfo = wx.getStorageSync('userInfo');
      console.log('userInfo:' + JSON.stringify(userInfo) );
      this.setData({
        userId: userInfo.id,
      });
    }

    this.getMyCommission();
  },

  /**
   * 生命周期函数--监听页面隐藏
   */
  onHide: function () {

  },

  /**
   * 生命周期函数--监听页面卸载
   */
  onUnload: function () {

  },

  /**
   * 页面相关事件处理函数--监听用户下拉动作
   */
  onPullDownRefresh: function () {

  },

  /**
   * 页面上拉触底事件的处理函数
   */
  onReachBottom: function () {

  },

  /**
   * 用户点击右上角分享
   */
  onShareAppMessage: function () {

  },
  goOrders(){
    wx.navigateTo({
      url: "/pages/ucenter/order/order?sellerId=" + this.data.userId +"&showType=3"
    })
  },
  goTeam(){
    wx.navigateTo({
      url: "/pages/ucenter/team/team"
    })
  }
})